<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<?php
$this->addCssFile('/project/apps/ecga/styles/style.css');
$this->addCssFile('/project/apps/ecga/styles/form.css');

$this->addScriptFile('/statics/js/mootools/core.js');
$this->addScriptFile('/statics/js/mootools/more.js');
?>
<body>
    <?php $this->import('tips'); ?>

    <div class="action-header">
        <h3><?php  $this->put('管理员添加');?></h3>
        <p class="action-desc"><?php $this->put('您可以在这里添加管理员的信息，或者点击这里返回'); ?><?php $this->txtLink('管理员列表', './master.php?a=show'); ?>。</p>
    </div>


    <form id="theForm" action="./master.php?a=<?php $this->ifput(isset($id), 'doEdit', 'doAdd');?>" method="post" enctype="multipart/form-data">
        <div class="box">
            <div class="head">
                <p><?php $this->put('基本信息'); ?></p>
            </div>
            <div class="body">
                <dl class="formrow">
                    <dt>
                        <?php $this->put('管理员姓名:');?>
                    </dt>
                    <dd>
                        <input type="hidden" name="formHash" value="<?php $this->put($formHash);?>" />
                        <input type="text"  name="userName"  value="<?php $this->put($data->userName);?>" class="text required msgPos:'masterNameAdvice'" />
                        <div id="masterNameAdvice" class="hint"></div>
                        <div class="field-hints">管理员姓名系统唯一，不能重复。</div>
                    </dd>
                </dl>
                <dl class="formrow">
                    <dt>
                        <?php $this->put('邮箱地址:'); ?>
                    </dt>
                    <dd>
                        <input type="text" name="userEmail" value="<?php $this->put($data->userEmail);?>" class="text required validate-email msgPos:'emailRequired'" />
                        <div class="hint" id="emailRequired"></div>
                        <div class="field-hints">为保证被添加的管理员能收到登录密码，请您填写正确的邮箱地址。邮箱地址系统唯一，不能重复。</div>
                    </dd>
                </dl>

                <dl class="formrow">
					<dt>
						<?php $this->put('用户权限:');?>
					</dt>
					<dd>
						<select name="userProjectPrivs[]" multiple size="10" class="auth-selectbox required valide-one-selected msgPos:'userProjectPrivs'">
                            <option value="">请选择</option>
                            <?php foreach ($projectOptions as $projectId => $projectName):?>
                            <optgroup label="<?php $this->put($projectName);?>">
                                <?php foreach ($authOptions as $authTable => $authTitle):?>
                                <option value="<?php $this->put($projectId);?>-<?php $this->put($authTable);?>" <?php $this->ifput(in_array($authTable, isset($userAuths[$projectId]['privs']) ? $userAuths[$projectId]['privs'] : array()), 'selected', '');?>><?php $this->put($authTitle);?></option>
                                <?php endforeach;?>
                            </optgroup>
                            <?php endforeach;?>
                        </select>
                        <div class="hint" id="userProjectPrivs"></div>
					</dd>
                </dl>
            </div>
        </div>
        <div class="buttonrow">
        	<?php if (isset($id)) : ?>
        	<input type="hidden" name="id" value="<?php $this->put($id)?>" />
        	<?php endif;?>
            <input type="submit" class="submit" value="<?php $this->put('保存管理员信息'); ?>"/>
        </div>
    </form>
    <?php $this->import('footer'); ?>
</body>

<script type="text/javascript">
window.addEvent('domready', function() {
    myFormValidator = new Form.Validator.Inline('theForm', {
        evaluateFieldsOnChange: false
    });
});
</script>
</html>